﻿<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:DPE.TED.OCAF.Win8SampleClient"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:uiHelpers="using:DPE.TED.OCAF.Win8SampleClient.UI_Helpers"
    xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" 
    xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
    x:Class="DPE.TED.OCAF.Win8SampleClient.MainPage"
    mc:Ignorable="d">

	<Page.DataContext>
		<Binding Path="Main" Source="{StaticResource Locator}"/>
	</Page.DataContext>

    <Page.BottomAppBar>
        <AppBar>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50*"/>
                    <ColumnDefinition Width="50*"/>
                </Grid.ColumnDefinitions>
                <StackPanel x:Name="LeftPanel" Orientation="Horizontal" Grid.Column="0" HorizontalAlignment="Left">
                    <ComboBox x:Name="DocumentFolder" ItemsSource="{Binding FolderList, Mode=OneWay}" SelectedValue="{Binding SelectedFolder, Mode=TwoWay}"  Height="32" Width="200" 
                              Margin="20,0">
                		<Interactivity:Interaction.Behaviors>
                			<Core:EventTriggerBehavior EventName="SelectionChanged">
                				<Core:InvokeCommandAction Command="{Binding SwitchFolderCommand}"/>
                			</Core:EventTriggerBehavior>
                		</Interactivity:Interaction.Behaviors>
                	</ComboBox>
                    <ProgressBar Height="28" Width="300" Minimum="0" Maximum="100" Value="{Binding SyncProgressValue}" IsIndeterminate="{Binding SyncProgressIndeterminate}" Opacity="{Binding SyncProgressVisibility}"   />
                    <TextBlock Text="{Binding ConnectionStatus, Mode=TwoWay}" FontSize="24" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,0"></TextBlock>
                </StackPanel>
                <StackPanel x:Name="RightPanel" Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="1">
                	<AppBarButton Command="{Binding RefreshCommand}" x:Uid="Insert" Icon="Refresh"  Label="Refresh"/>
                	<AppBarButton Command="{Binding InsertCommand}" x:Uid="Insert" Icon="Add" Label="Insert"/>
                	<AppBarButton Command="{Binding DeleteCommand}" x:Uid="Delete" Icon="Delete" Label="Delete" />
                	<AppBarSeparator/>
                    <AppBarButton Command="{Binding SyncCommand}" x:Uid="Sync" Icon="Sync" Label="Sync">
                    </AppBarButton>
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.BottomAppBar>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
	<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
		<Grid.ChildrenTransitions>
			<TransitionCollection>
				<EntranceThemeTransition/>
			</TransitionCollection>
		</Grid.ChildrenTransitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="140"/>
			<RowDefinition Height="*"/>
			<RowDefinition Height="10"/>
		</Grid.RowDefinitions>

		<!-- Back button and page title -->
		<Grid Grid.Row="0">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="120"/>
				<ColumnDefinition Width="*"/>
			</Grid.ColumnDefinitions>
			<TextBlock x:Name="pageTitle" Text="{Binding AppName}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
				IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40"/>
		</Grid>

        <!-- Horizontal scrolling grid -->
		<GridView Grid.Row="1"
			ItemsSource="{Binding PdfList}"
			x:Name="ItemGridView"
			AutomationProperties.AutomationId="ItemsGridView"
			AutomationProperties.Name="Items"
			TabIndex="1"
			Grid.RowSpan="2"
			Padding="50,50"
			SelectionMode="Single"
			IsSwipeEnabled="true"
			SelectedItem="{Binding SelectedPdf, Mode=TwoWay}"
			IsRightTapEnabled="True"
			IsItemClickEnabled="True">
			<Interactivity:Interaction.Behaviors>
                <Core:EventTriggerBehavior EventName="ItemClick">
                    <Core:InvokeCommandAction Command="{Binding ViewCommand}" />
                </Core:EventTriggerBehavior>
            </Interactivity:Interaction.Behaviors>
			<GridView.ItemTemplate>
				<DataTemplate>
                    <Border BorderBrush="Gray" BorderThickness="2">
					    <Grid HorizontalAlignment="Left" Width="350" Height="90" >
                        
						    <StackPanel VerticalAlignment="Top" Background="WhiteSmoke" >
							    
							    <TextBlock Text="{Binding FileName}" FontSize="20" Height="150" Margin="15,5,15,5" FontWeight="SemiBold" TextWrapping="Wrap" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                <Image Source="{Binding SyncFile.Thumbnail}"/>
						    </StackPanel>
					    </Grid>
                    </Border>
				</DataTemplate>
			</GridView.ItemTemplate>
		</GridView>
	</Grid>

</Page>
